public class Animal {
    public String name;
    public int age;
    public int size;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("含有两个参数的构造方法！");
    }

    public void eat(){
        System.out.println("正在吃饭");
    }
}
class Dog extends Animal{

    public Dog(){
        super("七月",10);//该构造方法加载后，继承了父类的子类不再报错
    }
    public Dog(String name,int age){//除了上面那个方法，这个也可以调用父类的构造方法
        super(name,age);//实例化dog的时候顺便实例化animal
    }
    public void wangwang(){
        System.out.println(name + "汪汪叫！");
    }
}
class Cat extends Animal{
    public Cat(){
        super("七月",10);//该构造方法加载后，继承了父类的子类不再报错
    }
    public void mew(){
        System.out.println(name + "正在喵喵叫！");
    }
    public Cat(String name,int age,int size){
        super(name,age);
        this.size = size;//先初始化父类，再初始化自己的size。否则会报错
    }
}
class Test{
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.name = "坦克";
        dog.wangwang();
        dog.eat();
        System.out.println("===============");
        Cat cat = new Cat();
        cat.name = "咪咪";
        cat.mew();

    }
}
